package com.cloud.common.redislock;

import com.cloud.common.utils.UuidUtil;

//加锁设置的参数
public class LockParam {
    //锁的key
    private String lockKey;
    //redis加锁的vlaus:每一个实例有不相同的UUID
    private String lockValue;


    //尝试获得锁的时间（单位：毫秒），默认值：3000毫秒
    private Long tryLockTime;
    //尝试获得锁后，持有锁的时间（单位：秒），默认值：5000毫秒
    private int holdLockTime;

    public String getLockValue() {
        return lockValue;
    }

    public void setLockValue(String lockValue) {
        this.lockValue = lockValue;
    }

    public LockParam(String lockKey){
        this(lockKey,1000*3L,5);
    };
    public LockParam(String lockKey, Long tryLockTime){
        this(lockKey,tryLockTime,5);
    };
    public LockParam(String lockKey, Long tryLockTime, Integer holdLockTime){
        this.lockKey = lockKey;
        this.tryLockTime = tryLockTime;
        this.holdLockTime = holdLockTime;
        this.lockValue= UuidUtil.getUuid();
    };


    public String getLockKey() {
        return lockKey;
    }

    public void setLockKey(String lockKey) {
        this.lockKey = lockKey;
    }

    public Long getTryLockTime() {
        return tryLockTime;
    }

    public void setTryLockTime(Long tryLockTime) {
        this.tryLockTime = tryLockTime;
    }

    public int getHoldLockTime() {
        return holdLockTime;
    }

    public void setHoldLockTime(int holdLockTime) {
        this.holdLockTime = holdLockTime;
    }
}
